package com.app.controller;


import com.app.common.ResponseResult;
import com.app.entity.vo.UserVo;
import com.app.enums.ResponseEnum;
import com.app.form.UserLoginForm;
import com.app.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yeyuan
 * @since 2021-11-27
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    @PostMapping("/login")
    public ResponseResult Login(@Valid @RequestBody UserLoginForm userLoginForm){
        UserVo userVo = userService.Login(userLoginForm);
        if(userVo == null)return ResponseResult.error(ResponseEnum.USERNAME_EXIST);
        return ResponseResult.success(userVo);
    }




}
